(function($){
	
	$.fn.inputState = function(text){	
		var object = $(this);
		var background1 = '#FFFFFF';
		var background2 = '#EAEAEA';
		var color1 = '#003743';
		var color2 = '#C5C5C5';		
		
		if(object.attr('value').trim() == '' || object.attr('value').trim() == text ){
			object.attr('value', text);
			object.css('background', background2) ;
			object.css('color', color2) ;
		}else{
			object.css('background', background1) ;
			object.css('color', color1) ;
		}
		
		object.focus(function(){	
			if(object.attr('value') == text) {
				object.attr('value', '');
				object.css('background', background1) ;
				object.css('color', color1) ;
			}		
		});

		object.blur(function(){		
			if(object.attr('value').trim() == '' || object.attr('value').trim() == text ){
				object.attr('value', text);
				object.css('background', background2) ;
				object.css('color', color2) ;
			}else{
				object.css('background', background1) ;
				object.css('color', color1) ;
			}
		});
	};
	
})(jQuery);

(function($){
	$.message = function(params){

		var buttonHTML = '';
		
		$.each(params.buttons,function(name, object){			
			buttonHTML += '<em class="button">'+object.name+'</em>';
		});
		
		var markup = '<div id="dialogOverlay"><div style="width:'+params.width+'px;" id="dialogBox"><h1 style="cursor:move;">'+params.title+'</h1><p style="text-align:left;"></p><div id="dialogButtons">' +buttonHTML+ '<div style="clear:both;"></div></div></div></div>';
        
		$(markup).hide().appendTo('body').show();
		
		if (params.message instanceof jQuery){
			params.message.appendTo('#dialogBox p');
		}else{
			$('#dialogBox p').html(params.message);
		}			
		
		var winH = $(window).height();
		var winW = $(window).width();
              
		$('#dialogBox').css('top', (winH/2-$('#dialogBox').height()/2) - 50);
		$('#dialogBox').css('left', winW/2-$('#dialogBox').width()/2);
		$('#dialogBox').draggable();
		
		var buttons = $('#dialogButtons em[class=button]');
		var i=0;

		$.each(params.buttons,function(name, obj){
			buttons.eq(i++).click(function(){	
				if (params.count == 2){
					$('#dialogOverlay').remove();
					if (obj.action != null)
						obj.action();
				}else{
					if (obj.action != null)
					obj.action();
					$('#dialogOverlay').remove();
				}
				
			});
		});
	};


})(jQuery);

(function($){
	$.urlframe = function(params){

		var buttonHTML = '';
		
		$.each(params.buttons,function(name, object){			
			buttonHTML += '<em class="button">'+object.name+'</em>';
		});
		
		var markup = '<div id="dialogOverlay"><div id="dialogBox"><h1 style="cursor:move;">'+params.title+'</h1><iframe style="width:400px;height:300px" id="dialogFrame" src="'+ params.url + '"></iframe><div id="dialogButtons">' +buttonHTML+ '<div style="clear:both;"></div></div></div></div>';
        
		$(markup).hide().appendTo('body').show();		
		
		var winH = $(window).height();
		var winW = $(window).width();
              
		$('#dialogBox').css('top', (winH/2-$('#dialogBox').height()/2) - 50);
		$('#dialogBox').css('left', winW/2-$('#dialogBox').width()/2);
		//$('#dialogBox').draggable();
		
		var buttons = $('#dialogButtons em[class=button]');
		var i=0;

		$.each(params.buttons,function(name, obj){
			buttons.eq(i++).click(function(){	
				if (params.count == 2){
					$('#dialogOverlay').remove();
					if (obj.action != null)
						obj.action();
				}else{
					if (obj.action != null)
					obj.action();
					$('#dialogOverlay').remove();
				}
				
			});
		});
	};
	
	
})(jQuery);

(function($){
	
	$.prop = function(param){	

		var data = {
				'cancel'		: 'Cancel',
				'delete.data'	: 'Delete data',
				'info'			: 'Info',
				'ok'			: 'OK',
				'unit'			: 'Unit'
		};
	
		return data[param];
	};
			
})(jQuery);
